package com.qf.utils;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;

/**
 * @version v1.0.0
 * @Description:
 * @author: 姜红凯
 * @date: 2022.03.07
 * @since 1.0
 */
public class EsClient {
    public static RestHighLevelClient creatClint(){
        //1. 创建和服务器的连接
        HttpHost httpHost = new HttpHost("192.168.224.128",9200);
        //2. 创建RestClient对象
        RestClientBuilder builder = RestClient.builder(httpHost);
        //3. 创建返回可以使用的连接对象
        RestHighLevelClient highLevelClient = new RestHighLevelClient(builder);
        return highLevelClient;
    }
}
